<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Cencat SaaS - AI代码生成器</title>
  <script src="https://cdn.tailwindcss.com"></script>
  <link href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet">
  
  <script>
    tailwind.config = {
      theme: {
        extend: {
          colors: {
            primary: '#165DFF',
            secondary: '#36CFC9',
            success: '#52C41A',
            warning: '#FAAD14',
            danger: '#FF4D4F',
            info: '#40A9FF',
            dark: '#1D2129',
            'dark-2': '#4E5969',
            'light-1': '#F2F3F5',
            'light-2': '#E5E6EB',
            'light-3': '#C9CDD4'
          },
          fontFamily: {
            inter: ['Inter', 'system-ui', 'sans-serif'],
          },
          boxShadow: {
            'card': '0 2px 14px 0 rgba(0, 0, 0, 0.06)',
            'card-hover': '0 6px 20px 0 rgba(0, 0, 0, 0.1)',
            'dropdown': '0 4px 16px rgba(0, 0, 0, 0.12)',
            'modal': '0 10px 30px -5px rgba(0, 0, 0, 0.1)',
          }
        },
      }
    }
  </script>
  
  <style>
    body { font-family: 'Inter', system-ui, sans-serif; overflow-x: hidden; }
    html { scroll-behavior: smooth; }
    .progress-bar { transition: width 1s ease-in-out; }
    .table-row-hover { transition: background-color 0.2s ease; }
    .table-row-hover:hover { background-color: rgba(242, 243, 245, 0.5); }
    
    @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
    @keyframes slideIn { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
    .animate-fade-in { animation: fadeIn 0.3s ease-in-out; }
    .animate-slide-in { animation: slideIn 0.3s ease-out; }
    
    .code-block { font-family: 'Courier New', monospace; font-size: 14px; }
    .ai-response { border-left: 4px solid #36CFC9; }
  </style>
</head>

<body class="bg-light-1 text-dark overflow-x-hidden">
  <div class="flex h-screen">
    <!-- 侧边栏导航 -->
    <aside id="sidebar" class="w-64 bg-white h-full shadow-md fixed left-0 top-0 z-30 transition-all duration-300 transform md:translate-x-0 -translate-x-full">
      <div class="p-4 border-b border-light-2 flex items-center space-x-3">
        <div class="w-10 h-10 bg-primary rounded-lg flex items-center justify-center">
          <i class="fa fa-cubes text-white text-xl"></i>
        </div>
        <div>
          <h1 class="text-lg font-bold text-primary">Cencat SaaS</h1>
          <p class="text-xs text-dark-2">多租户管理平台</p>
        </div>
        <button id="close-sidebar" class="ml-auto md:hidden text-dark-2 hover:text-primary">
          <i class="fa fa-times"></i>
        </button>
      </div>
      
      <div class="p-4 border-b border-light-2">
        <div class="flex items-center space-x-3">
          <div class="w-10 h-10 bg-light-1 rounded-full overflow-hidden">
            <img src="https://picsum.photos/id/1005/200/200" alt="当前租户Logo" class="w-full h-full object-cover">
          </div>
          <div>
            <p class="font-medium text-sm">云帆科技有限公司</p>
            <p class="text-xs text-dark-2">企业版 | ID: T2025001</p>
          </div>
        </div>
        <button id="switch-tenant-btn" class="mt-3 w-full text-xs text-primary hover:text-primary/80 flex items-center justify-center space-x-1 transition-all duration-300">
          <i class="fa fa-exchange"></i>
          <span>切换租户</span>
        </button>
      </div>
      
      <nav class="p-3">
        <ul class="space-y-1">
          <li class="text-xs font-semibold text-dark-2 uppercase tracking-wider px-3 py-2">主导航</li>
          
          <li>
            <a href="dashboard.html" class="flex items-center px-3 py-2.5 text-sm rounded-lg text-dark hover:bg-light-1 group transition-all duration-300">
              <i class="fa fa-dashboard w-5 h-5 mr-3 text-dark-2 group-hover:text-dark transition-all duration-300"></i>
              <span>仪表盘</span>
            </a>
          </li>
          
          <li>
            <a href="tenants.html" class="flex items-center px-3 py-2.5 text-sm rounded-lg text-dark hover:bg-light-1 group transition-all duration-300">
              <i class="fa fa-building-o w-5 h-5 mr-3 text-dark-2 group-hover:text-dark transition-all duration-300"></i>
              <span>租户管理</span>
            </a>
          </li>
          
          <li class="text-xs font-semibold text-dark-2 uppercase tracking-wider px-3 py-2 mt-4">AI赋能功能</li>
          
          <li>
            <a href="ai-code-generator.html" class="flex items-center px-3 py-2.5 text-sm rounded-lg bg-primary/10 text-primary group transition-all duration-300">
              <i class="fa fa-code w-5 h-5 mr-3"></i>
              <span>AI代码生成</span>
            </a>
          </li>
          
          <li>
            <a href="ai-log-diagnosis.html" class="flex items-center px-3 py-2.5 text-sm rounded-lg text-dark hover:bg-light-1 group transition-all duration-300">
              <i class="fa fa-bug w-5 h-5 mr-3 text-dark-2 group-hover:text-dark transition-all duration-300"></i>
              <span>日志智能诊断</span>
            </a>
          </li>
          
          <li>
            <a href="ai-customer-service.html" class="flex items-center px-3 py-2.5 text-sm rounded-lg text-dark hover:bg-light-1 group transition-all duration-300">
              <i class="fa fa-comments-o w-5 h-5 mr-3 text-dark-2 group-hover:text-dark transition-all duration-300"></i>
              <span>智能客服</span>
            </a>
          </li>
          
          <li>
            <a href="low-code-platform.html" class="flex items-center px-3 py-2.5 text-sm rounded-lg text-dark hover:bg-light-1 group transition-all duration-300">
              <i class="fa fa-puzzle-piece w-5 h-5 mr-3 text-dark-2 group-hover:text-dark transition-all duration-300"></i>
              <span>低代码平台</span>
            </a>
          </li>
          
          <li class="text-xs font-semibold text-dark-2 uppercase tracking-wider px-3 py-2 mt-4">系统管理</li>
          
          <li>
            <a href="configurations.html" class="flex items-center px-3 py-2.5 text-sm rounded-lg text-dark hover:bg-light-1 group transition-all duration-300">
              <i class="fa fa-key w-5 h-5 mr-3 text-dark-2 group-hover:text-dark transition-all duration-300"></i>
              <span>配置管理</span>
            </a>
          </li>
          
          <li class="text-xs font-semibold text-dark-2 uppercase tracking-wider px-3 py-2 mt-4">系统设置</li>
          
          <li>
            <a href="packages.html" class="flex items-center px-3 py-2.5 text-sm rounded-lg text-dark hover:bg-light-1 group transition-all duration-300">
              <i class="fa fa-tags w-5 h-5 mr-3 text-dark-2 group-hover:text-dark transition-all duration-300"></i>
              <span>套餐管理</span>
            </a>
          </li>
          
          <li>
            <a href="security.html" class="flex items-center px-3 py-2.5 text-sm rounded-lg text-dark hover:bg-light-1 group transition-all duration-300">
              <i class="fa fa-shield w-5 h-5 mr-3 text-dark-2 group-hover:text-dark transition-all duration-300"></i>
              <span>安全设置</span>
            </a>
          </li>
          
          <li>
            <a href="logs.html" class="flex items-center px-3 py-2.5 text-sm rounded-lg text-dark hover:bg-light-1 group transition-all duration-300">
              <i class="fa fa-file-text-o w-5 h-5 mr-3 text-dark-2 group-hover:text-dark transition-all duration-300"></i>
              <span>操作日志</span>
            </a>
          </li>
        </ul>
      </nav>
      
      <div class="absolute bottom-0 left-0 right-0 p-4 border-t border-light-2">
        <div class="bg-light-1 rounded-lg p-3">
          <div class="flex items-center justify-between mb-2">
            <span class="text-xs text-dark-2">AI调用次数</span>
            <span class="text-xs font-medium">128 / 500</span>
          </div>
          <div class="h-1.5 bg-light-2 rounded-full overflow-hidden">
            <div class="h-full bg-secondary rounded-full progress-bar" style="width: 25.6%"></div>
          </div>
          <button class="mt-2 w-full text-xs bg-secondary/10 text-secondary py-1.5 rounded hover:bg-secondary/20 transition-all duration-300">
            升级AI配额
          </button>
        </div>
      </div>
    </aside>

    <!-- 主内容区 -->
    <div class="flex-1 md:ml-64 transition-all duration-300">
      <!-- 顶部导航栏 -->
      <header class="bg-white shadow-sm sticky top-0 z-20">
        <div class="flex items-center justify-between p-4">
          <div class="flex items-center">
            <button id="toggle-sidebar" class="mr-4 text-dark-2 hover:text-primary md:hidden">
              <i class="fa fa-bars text-xl"></i>
            </button>
            <div class="relative">
              <input type="text" placeholder="搜索AI功能..." class="pl-10 pr-4 py-2 rounded-lg bg-light-1 text-sm w-64 focus:outline-none focus:ring-2 focus:ring-primary/30">
              <i class="fa fa-search absolute left-3 top-1/2 transform -translate-y-1/2 text-dark-2"></i>
            </div>
          </div>
          
          <div class="flex items-center space-x-4">
            <div class="relative">
              <button id="notification-btn" class="w-10 h-10 rounded-full flex items-center justify-center hover:bg-light-1 relative transition-all duration-300">
                <i class="fa fa-bell-o text-dark-2"></i>
                <span class="absolute top-1 right-1 w-2 h-2 bg-danger rounded-full"></span>
              </button>
            </div>
            
            <button class="w-10 h-10 rounded-full flex items-center justify-center hover:bg-light-1 transition-all duration-300">
              <i class="fa fa-question text-dark-2"></i>
            </button>
            
            <div class="relative">
              <button id="user-menu-btn" class="flex items-center space-x-2">
                <div class="w-9 h-9 rounded-full overflow-hidden border-2 border-transparent hover:border-primary transition-all duration-300">
                  <img src="https://picsum.photos/id/1012/200/200" alt="管理员头像" class="w-full h-full object-cover">
                </div>
                <div class="hidden md:block text-left">
                  <p class="text-sm font-medium">张管理员</p>
                  <p class="text-xs text-dark-2">超级管理员</p>
                </div>
                <i class="fa fa-angle-down text-dark-2 hidden md:block"></i>
              </button>
            </div>
          </div>
        </div>
      </header>

      <!-- 页面内容 -->
      <main class="p-4 md:p-6">
        <!-- 页面标题和操作 -->
        <div class="mb-6 animate-fade-in flex flex-col md:flex-row md:items-center justify-between gap-4">
          <div>
            <h2 class="text-[clamp(1.5rem,3vw,2rem)] font-bold text-dark">AI代码生成器</h2>
            <p class="text-dark-2 mt-1">基于自然语言描述自动生成高质量代码</p>
          </div>
          
          <div class="flex space-x-3">
            <button class="bg-light-1 text-dark hover:bg-light-2 text-sm px-4 py-2 rounded-lg transition-all duration-300 flex items-center">
              <i class="fa fa-history mr-2"></i>
              <span>历史记录</span>
            </button>
            
            <button class="bg-secondary text-white text-sm px-4 py-2 rounded-lg hover:bg-secondary/90 transition-all duration-300 flex items-center">
              <i class="fa fa-magic mr-2"></i>
              <span>模板库</span>
            </button>
          </div>
        </div>

        <!-- AI代码生成器主界面 -->
        <div class="grid grid-cols-1 lg:grid-cols-2 gap-6 mb-6">
          <!-- 输入区域 -->
          <div class="bg-white rounded-xl shadow-card p-6 animate-slide-in">
            <h3 class="text-lg font-semibold mb-4">描述你的需求</h3>
            
            <div class="mb-4">
              <label class="block text-sm font-medium text-dark-2 mb-2">选择生成类型</label>
              <div class="grid grid-cols-3 gap-2">
                <button class="bg-primary text-white text-sm py-2 rounded-lg transition-all duration-300" data-type="entity">Java实体类</button>
                <button class="bg-light-1 text-dark hover:bg-light-2 text-sm py-2 rounded-lg transition-all duration-300" data-type="service">Service层</button>
                <button class="bg-light-1 text-dark hover:bg-light-2 text-sm py-2 rounded-lg transition-all duration-300" data-type="controller">Controller层</button>
                <button class="bg-light-1 text-dark hover:bg-light-2 text-sm py-2 rounded-lg transition-all duration-300" data-type="vue">Vue页面</button>
                <button class="bg-light-1 text-dark hover:bg-light-2 text-sm py-2 rounded-lg transition-all duration-300" data-type="sql">SQL语句</button>
                <button class="bg-light-1 text-dark hover:bg-light-2 text-sm py-2 rounded-lg transition-all duration-300" data-type="crud">完整CRUD</button>
              </div>
            </div>
            
            <div class="mb-4">
              <label class="block text-sm font-medium text-dark-2 mb-2">自然语言描述</label>
              <textarea id="ai-prompt" class="w-full h-40 p-3 border border-light-2 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary/30 resize-none" placeholder="例如：生成商品入库单CRUD接口，包含验重和库存预警功能，需要租户隔离..."></textarea>
              <div class="flex justify-between mt-1">
                <span class="text-xs text-dark-2">支持中英文描述</span>
                <span class="text-xs text-dark-2">0/1000字符</span>
              </div>
            </div>
            
            <div class="mb-4">
              <label class="block text-sm font-medium text-dark-2 mb-2">高级选项</label>
              <div class="grid grid-cols-2 gap-3">
                <div>
                  <label class="text-xs text-dark-2">框架选择</label>
                  <select id="framework-select" class="w-full p-2 border border-light-2 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-primary/30">
                    <option value="spring-mybatis">Spring Boot + MyBatis-Plus</option>
                    <option value="spring-jpa">Spring Boot + JPA</option>
                    <option value="vue3">Vue 3 + Element Plus</option>
                    <option value="react">React + Ant Design</option>
                  </select>
                </div>
                <div>
                  <label class="text-xs text-dark-2">代码风格</label>
                  <select id="code-style" class="w-full p-2 border border-light-2 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-primary/30">
                    <option value="alibaba">阿里巴巴规范</option>
                    <option value="google">Google规范</option>
                    <option value="custom">自定义规范</option>
                  </select>
                </div>
              </div>
            </div>
            
            <div class="mb-4">
              <label class="block text-sm font-medium text-dark-2 mb-2">租户隔离配置</label>
              <div class="space-y-2">
                <label class="flex items-center space-x-2">
                  <input type="checkbox" id="tenant-isolation" checked class="rounded">
                  <span class="text-sm">启用租户隔离 (@TenantId注解)</span>
                </label>
                <label class="flex items-center space-x-2">
                  <input type="checkbox" id="data-permission" class="rounded">
                  <span class="text-sm">启用数据权限控制</span>
                </label>
                <label class="flex items-center space-x-2">
                  <input type="checkbox" id="audit-log" class="rounded">
                  <span class="text-sm">启用操作审计日志</span>
                </label>
              </div>
            </div>
            
            <button id="generate-code" class="w-full bg-primary text-white py-3 rounded-lg hover:bg-primary/90 transition-all duration-300 flex items-center justify-center">
              <i class="fa fa-bolt mr-2"></i>
              <span>生成代码</span>
            </button>
          </div>

          <!-- 输出区域 -->
          <div class="bg-white rounded-xl shadow-card p-6 animate-slide-in">
            <h3 class="text-lg font-semibold mb-4">生成的代码</h3>
            
            <div class="mb-4">
              <div class="flex space-x-2 mb-3">
                <button class="text-sm text-primary border-b-2 border-primary pb-1">Java实体类</button>
                <button class="text-sm text-dark-2 hover:text-dark pb-1">Service层</button>
                <button class="text-sm text-dark-2 hover:text-dark pb-1">Controller层</button>
                <button class="text-sm text-dark-2 hover:text-dark pb-1">Vue页面</button>
              </div>
              
              <div class="bg-dark text-white rounded-lg p-4 code-block overflow-x-auto">
                <pre><code>// 商品入库单实体类（带租户隔离）
@Entity
@Table(name = "product_stock_in")
@Data
@EqualsAndHashCode(callSuper = true)
public class ProductStockIn extends BaseEntity {
    
    @TenantId
    private Long tenantId;
    
    @NotBlank(message = "入库单号不能为空")
    private String stockInNo;
    
    @NotNull(message = "商品ID不能为空")
    private Long productId;
    
    @NotBlank(message = "商品编码不能为空")
    private String productCode;
    
    @NotNull(message = "入库数量不能为空")
    @Min(value = 1, message = "入库数量必须大于0")
    private Integer quantity;
    
    @NotNull(message = "入库时间不能为空")
    private LocalDateTime stockInTime;
    
    private String remark;
    
    // 库存预警字段
    private Boolean stockWarning;
    private String warningMessage;
}</code></pre>
              </div>
            </div>
            
            <div class="ai-response bg-light-1 rounded-lg p-4 mb-4">
              <div class="flex items-center mb-2">
                <i class="fa fa-lightbulb-o text-secondary mr-2"></i>
                <span class="font-medium">AI优化建议</span>
              </div>
              <p class="text-sm">建议为product_code字段添加唯一索引，避免重复入库。同时建议添加库存预警阈值配置表。</p>
            </div>
            
            <div class="flex space-x-3">
              <button class="flex-1 bg-success text-white py-2 rounded-lg hover:bg-success/90 transition-all duration-300 flex items-center justify-center">
                <i class="fa fa-download mr-2"></i>
                <span>下载代码</span>
              </button>
              <button class="flex-1 bg-primary text-white py-2 rounded-lg hover:bg-primary/90 transition-all duration-300 flex items-center justify-center">
                <i class="fa fa-copy mr-2"></i>
                <span>复制代码</span>
              </button>
            </div>
          </div>
        </div>

        <!-- 代码模板库 -->
        <div class="bg-white rounded-xl shadow-card p-6 animate-slide-in mb-6">
          <h3 class="text-lg font-semibold mb-4">常用代码模板</h3>
          
          <div class="grid grid-cols-1 md:grid-cols-3 gap-4">
            <div class="border border-light-2 rounded-lg p-4 hover:border-primary transition-all duration-300 cursor-pointer">
              <div class="flex items-center mb-2">
                <i class="fa fa-database text-primary mr-2"></i>
                <span class="font-medium">基础CRUD模板</span>
              </div>
              <p class="text-sm text-dark-2">包含增删改查、分页查询、条件查询等基础功能</p>
            </div>
            
            <div class="border border-light-2 rounded-lg p-4 hover:border-primary transition-all duration-300 cursor-pointer">
              <div class="flex items-center mb-2">
                <i class="fa fa-shield text-success mr-2"></i>
                <span class="font-medium">权限管理模板</span>
              </div>
              <p class="text-sm text-dark-2">用户、角色、权限管理，支持RBAC权限模型</p>
            </div>
            
            <div class="border border-light-2 rounded-lg p-4 hover:border-primary transition-all duration-300 cursor-pointer">
              <div class="flex items-center mb-2">
                <i class="fa fa-file-text-o text-warning mr-2"></i>
                <span class="font-medium">文件管理模板</span>
              </div>
              <p class="text-sm text-dark-2">文件上传下载、预览、分片上传等完整功能</p>
            </div>
          </div>
        </div>

        <!-- 使用统计 -->
        <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
          <div class="bg-white rounded-xl shadow-card p-5">
            <div class="flex items-center justify-between">
              <div>
                <p class="text-sm text-dark-2">今日生成次数</p>
                <p class="text-2xl font-bold text-dark mt-1">12</p>
                <p class="text-xs text-success mt-1">较昨日 +3</p>
              </div>
              <div class="w-12 h-12 bg-primary/10 rounded-full flex items-center justify-center">
                <i class="fa fa-code text-primary text-xl"></i>
              </div>
            </div>
          </div>
          
          <div class="bg-white rounded-xl shadow-card p-5">
            <div class="flex items-center justify-between">
              <div>
                <p class="text-sm text-dark-2">代码质量评分</p>
                <p class="text-2xl font-bold text-dark mt-1">92.5</p>
                <p class="text-xs text-success mt-1">优秀水平</p>
              </div>
              <div class="w-12 h-12 bg-success/10 rounded-full flex items-center justify-center">
                <i class="fa fa-star text-success text-xl"></i>
              </div>
            </div>
          </div>
          
          <div class="bg-white rounded-xl shadow-card p-5">
            <div class="flex items-center justify-between">
              <div>
                <p class="text-sm text-dark-2">节省开发时间</p>
                <p class="text-2xl font-bold text-dark mt-1">156h</p>
                <p class="text-xs text-success mt-1">累计节省</p>
              </div>
              <div class="w-12 h-12 bg-secondary/10 rounded-full flex items-center justify-center">
                <i class="fa fa-clock-o text-secondary text-xl"></i>
              </div>
            </div>
          </div>
        </div>
      </main>
    </div>
  </div>

  <script>
    document.addEventListener('DOMContentLoaded', function() {
      // 侧边栏切换
      const sidebar = document.getElementById('sidebar');
      const toggleSidebar = document.getElementById('toggle-sidebar');
      const closeSidebar = document.getElementById('close-sidebar');
      
      toggleSidebar.addEventListener('click', function() {
        sidebar.classList.toggle('-translate-x-full');
      });
      
      closeSidebar.addEventListener('click', function() {
        sidebar.classList.add('-translate-x-full');
      });
      
      // 代码生成功能
      const generateBtn = document.getElementById('generate-code');
      const aiPrompt = document.getElementById('ai-prompt');
      const codeTypeButtons = document.querySelectorAll('[data-type]');
      let selectedType = 'entity';
      
      // 代码类型选择
      codeTypeButtons.forEach(button => {
        button.addEventListener('click', function() {
          const type = this.getAttribute('data-type');
          selectedType = type;
          
          // 更新按钮状态
          codeTypeButtons.forEach(btn => {
            btn.classList.remove('bg-primary', 'text-white');
            btn.classList.add('bg-light-1', 'text-dark', 'hover:bg-light-2');
          });
          this.classList.remove('bg-light-1', 'text-dark', 'hover:bg-light-2');
          this.classList.add('bg-primary', 'text-white');
          
          // 更新输出区域标签
          updateOutputTabs(type);
        });
      });
      
      // 更新输出标签
      function updateOutputTabs(type) {
        const tabs = document.querySelectorAll('.text-sm.pb-1');
        tabs.forEach(tab => {
          if (tab.textContent.includes(getTypeName(type))) {
            tab.classList.add('text-primary', 'border-b-2', 'border-primary');
            tab.classList.remove('text-dark-2', 'hover:text-dark');
          } else {
            tab.classList.remove('text-primary', 'border-b-2', 'border-primary');
            tab.classList.add('text-dark-2', 'hover:text-dark');
          }
        });
      }
      
      // 获取类型名称
      function getTypeName(type) {
        const typeMap = {
          'entity': 'Java实体类',
          'service': 'Service层',
          'controller': 'Controller层',
          'vue': 'Vue页面',
          'sql': 'SQL语句',
          'crud': '完整CRUD'
        };
        return typeMap[type] || 'Java实体类';
      }
      
      // 生成代码功能
      generateBtn.addEventListener('click', function() {
        if (aiPrompt.value.trim() === '') {
          alert('请输入代码生成描述');
          return;
        }
        
        // 模拟AI代码生成过程
        generateBtn.innerHTML = '<i class="fa fa-spinner fa-spin mr-2"></i><span>生成中...</span>';
        generateBtn.disabled = true;
        
        setTimeout(() => {
          generateBtn.innerHTML = '<i class="fa fa-bolt mr-2"></i><span>生成代码</span>';
          generateBtn.disabled = false;
          
          // 显示生成结果
          showGeneratedCode(aiPrompt.value, selectedType);
        }, 2000);
      });
      
      // 显示生成的代码
      function showGeneratedCode(prompt, type) {
        const codeExamples = {
          'entity': `// ${prompt} - 实体类代码
@Entity
@Table(name = "${getTableName(prompt)}")
@Data
@EqualsAndHashCode(callSuper = true)
public class ${getClassName(prompt)} extends BaseEntity {
    
    @TenantId
    private Long tenantId;
    
    @NotBlank(message = "字段不能为空")
    private String field1;
    
    @NotNull(message = "字段不能为空")
    private Integer field2;
    
    // 自动生成的字段和方法...
}`,
          'service': `// ${prompt} - Service层代码
@Service
@RequiredArgsConstructor
public class ${getClassName(prompt)}Service {
    
    private final ${getClassName(prompt)}Mapper mapper;
    
    public PageResult<${getClassName(prompt)}> list(${getClassName(prompt)}Query query) {
        Page<${getClassName(prompt)}> page = mapper.selectPage(query);
        return PageResult.of(page);
    }
    
    // 更多业务方法...`
        };
        
        const codeBlock = document.querySelector('pre code');
        codeBlock.textContent = codeExamples[type] || codeExamples.entity;
        
        // 显示AI优化建议
        showAISuggestions(prompt);
      }
      
      // 获取表名
      function getTableName(prompt) {
        return prompt.toLowerCase().replace(/[^a-z0-9]/g, '_') + '_table';
      }
      
      // 获取类名
      function getClassName(prompt) {
        return prompt.replace(/[^a-zA-Z0-9]/g, ' ').split(' ')
          .map(word => word.charAt(0).toUpperCase() + word.slice(1))
          .join('').replace(/\s+/g, '');
      }
      
      // 显示AI优化建议
      function showAISuggestions(prompt) {
        const suggestions = [
          '建议为关键字段添加数据库索引',
          '考虑添加输入参数验证',
          '推荐使用缓存提升性能',
          '建议添加操作日志记录',
          '考虑异常处理和重试机制'
        ];
        
        const randomSuggestion = suggestions[Math.floor(Math.random() * suggestions.length)];
        const aiResponse = document.querySelector('.ai-response p');
        aiResponse.textContent = randomSuggestion;
      }
      
      // 复制代码功能
      document.querySelector('.fa-copy').closest('button').addEventListener('click', function() {
        const code = document.querySelector('pre code').textContent;
        navigator.clipboard.writeText(code).then(() => {
          alert('代码已复制到剪贴板！');
        });
      });
    });
  </script>
</body>
</html>